import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
const originalPush = VueRouter.prototype.push;

VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
};

const routes = [{
        path: "/",
        name: "Home",
        redirect: "/home",
        meta: {
            title: "督导听课系统"
        }
    },
    {
        path: "/login",
        name: "Login",
        component: () =>
            import ( /* webpackChunkName: "login" */ "../views/Login.vue"),
        meta: {
            title: "CUIT_督导听课系统登录页"
        }
    },
    {
        path: "/home",
        name: "Home",
        component: Home,
        meta: {
            title: "CUIT_督导听课系统"
        },
        redirect: "/typeSelect",
        children: [{
                path: "/typeSelect",
                component: () =>
                    import (
                        /* webpackChunkName: "Listen" */
                        "../views/Listen/TypeSelect.vue"
                    ),
                meta: {
                    title: "督导听课系统_类型选择"
                }
            },
            {
                path: "/listening",
                component: () =>
                    import (
                        /* webpackChunkName: "Listen" */
                        "../views/Listen/ListeningList.vue"
                    ),
                meta: {
                    title: "督导听课系统_进行中的"
                }
            },
            {
                path: "/historyList",
                component: () =>
                    import (
                        /* webpackChunkName: "Listen" */
                        "../views/Listen/HistoryList.vue"
                    ),
                meta: {
                    title: "督导听课系统_历史听课"
                }
            },
            {
                path: "/setting",
                component: () =>
                    import ( /* webpackChunkName: "Listen" */ "../views/other/Setting.vue"),
                meta: {
                    title: "督导听课系统_设置"
                }
            },
            {
                path: "/addForm",
                component: () =>
                    import ( /* webpackChunkName: "Listen" */ "../views/form/addForm.vue"),
                meta: {
                    title: "督导听课系统_添加听课"
                }
            },
            {
                path: "/listen/details/:id",
                props: true,
                component: () =>
                    import (
                        /* webpackChunkName: "Listen" */
                        "../views/form/detailForm.vue"
                    ),
                meta: {
                    title: "督导员听课评价表"
                }
            },
            {
                path: "/historyDetails/:id",
                props: true,
                component: () =>
                    import (
                        /* webpackChunkName: "Listen" */
                        "../views/form/historyDetails.vue"
                    ),
                meta: {
                    title: "督导听课系统_听课详情"
                }
            }
        ]
    }
];

Vue.use(VueRouter);

const router = new VueRouter({
    mode: "history",
    base: process.env.BASE_URL,
    routes
});

export default router;